package com.ideaplugin.datamanager.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import com.ideaplugin.datamanager.model.common.PageRequest;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import com.ideaplugin.datamanager.model.common.PageResult;
import javax.validation.Valid;

/**
* @author zhaojingbo
* @since 2023-06-07
*/
@RestController
@RequestMapping("/${className?uncap_first?replace("Service","")}")
public class ${className?replace("Service","")}Controller {

@Autowired
private ${className} ${className?uncap_first};

<#list methods as method>

    @RequestMapping("/${method.name}")
    <#if method.paramClass?length gt 0>
        <#if method.returnType == 'PageResult'>
            public ${method.returnClass} ${method.name}(${method.paramClass} @RequestBody @Valid  param) {
            return ${className?uncap_first}.${method.name}(param);
        <#else>
            public ${method.returnClass} ${method.name}(${method.paramClass} param) {
            return new ${method.returnType}<>(${className?uncap_first}.${method.name}(param));
        </#if>
    <#else>
        public ${method.returnClass} ${method.name}() {
        <#if method.returnType == 'PageResult'>
            return ${className?uncap_first}.${method.name}();
        <#else>
            return new ${method.returnType}<>(${className?uncap_first}.${method.name}());
        </#if>
    </#if>
    }
</#list>


}
